﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using Microsoft.Practices.EnterpriseLibrary.Data;
using System.Data.Common;

namespace MINERP.DAL.CommonDAL
{
    public static class CommOperDB
    {
        //执行sql获得表
        public static DataTable ExceSQLDataTable(string instr)
        {

            Database db = null;


            DataTable table = new DataTable();
            try
            {

                db = DatabaseFactory.CreateDatabase();
                
                DbCommand dbCommand = db.GetSqlStringCommand(instr);
                dbCommand.CommandTimeout = 600;
                DataSet set = db.ExecuteDataSet(dbCommand);
                table = set.Tables[0];
            }
            catch
            {
                throw;
            }
            return table;
        }

        public static DataSet ExceSQLDataSet(string  str)
        {
            Database db = null;


            DataSet set = new DataSet();
            try
            {
                db = DatabaseFactory.CreateDatabase();

                DbCommand dbCommand = db.GetSqlStringCommand(str);
                 set = db.ExecuteDataSet(dbCommand);
               
            }
            catch
            {
                throw;
            }
            return set;
        }
    }
}
